package in.kmb.inval;

import java.io.InputStream;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;

/**
 * A Custom Drawable which allows us to log various life cycle events. 
 * @author Kiran Rao
 *
 */
public class CustomDrawable extends BitmapDrawable {
    
    
    public CustomDrawable(Resources res, Bitmap bitmap) {
        super(res, bitmap);
    }

    
    public CustomDrawable(Resources res, InputStream is) {
        super(res, is);
    }

    
    public CustomDrawable(Resources res, String filepath) {
        super(res, filepath);
    }

    public CustomDrawable(Resources res) {
        super(res);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void onBoundsChange(Rect bounds) {
        /*
         * We are over-riding this method to be able to log the 
         * bounds that have been supplied to this method.
         * 
         * This illustrates the issue - the bounds are being set to the original.
         * Even if we explicitly set bounds, immediately following our call, setBounds is being called
         * again with the original values.
         */
        Log.d(Constants.LOG_TAG, "CustomDrawable onBoundsChange(): bounds="+bounds);
        super.onBoundsChange(bounds);
    }

}
